//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft shared
// source or premium shared source license agreement under which you licensed
// this source code. If you did not accept the terms of the license agreement,
// you are not authorized to use this source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the SOURCE.RTF on your install media or the root of your tools installation.
// THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
// for various filters and stream control interfaces
#include <streams.h>
// for the encoder DMO
#include <dmodshow.h>
#include <dmoreg.h>
// for the camera driver guid
#include <camera.h>
// for CComVariants
#include <atlbase.h>
// for the WMV9 encoder clsid
#include <wmcodecids.h>

#include <streams.h>

#include <PropertyBag.h>
#include "MotionFilter.h"

#ifndef VIDEOCAPTUREGRAPH_H
#define VIDEOCAPTUREGRAPH_H

#define WM_DSHOWEVENT WM_USER+1

typedef class CVideoCaptureGraph
{
    public:
        CVideoCaptureGraph( );
        ~CVideoCaptureGraph( );
        void Cleanup();
        HRESULT BuildGraph(HWND OwnerWnd, RECT *rcCoordinates);
        HRESULT Reset();
        HRESULT GetEvent(long* lEventCode, long* lParam1, long* lParam2, long msTimeout);
        HRESULT FreeEvent(long lEventCode, long lParam1, long lParam2);
        HRESULT StartCapture();
        HRESULT StopCapture();

    private:
        HRESULT SetupCoreDirectShowComponents(HWND OwnerWnd);
        HRESULT SetupVideoCaptureFilter();
        HRESULT SetupPreview(HWND OwnerWnd, RECT *rc);
        HRESULT SetupCapture();

        ICaptureGraphBuilder2 *m_pCaptureGraphBuilder;
        IGraphBuilder *m_pGraph;
        IMediaControl *m_pMediaControl;
        IMediaEventEx *m_pMediaEvent;
        IBaseFilter *m_pVideoCapture;
        BOOL m_fInitialized;
}VIDEOCAPTUREGRAPH, *PVIDEOCAPTUREGRAPH;

#endif
